package com.pureut.storage.controller;

import com.pureut.storage.dto.MaterialChangeDto;
import com.pureut.storage.dto.WmsStockInfoDto;
import com.pureut.storage.service.MaterialChangeService;
import com.pureut.storage.vo.MaterialChangeVo;
import com.sale.common.core.domain.R;
import com.sale.common.core.web.controller.BaseController;
import com.sale.common.log.annotation.Log;
import com.sale.common.log.enums.BusinessType;
import com.sale.common.mybatis.core.page.PageQuery;
import com.sale.common.mybatis.core.page.TableDataInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: CM
 * @date: 2023/1/9  17:17
 */

@RestController
@RequestMapping("/materialChange")
public class MaterialChangeController extends BaseController {

    @Resource
    MaterialChangeService materialChangeService;

    /**
     *  物料变更新增查询仓库列表
     */
    @GetMapping("/viewStock/{number}")
    public R<WmsStockInfoDto> view(@PathVariable("number") String number) throws Exception {
        return R.ok(materialChangeService.viewStock(number));
    }

    /**
     *  物料变更新增明细
     */
    // @RequiresPermissions("material:accessories:addType")
    @Log(title = "新增物料变更", businessType = BusinessType.INSERT)
    @PostMapping("/addChange")
    public R<Void> addChange(@RequestBody MaterialChangeVo materialChangeVo) throws Exception {
        return toAjax(materialChangeService.addChange(materialChangeVo));
    }

    /**
     * 查看物料列表
     */
    @GetMapping("/list")
    public TableDataInfo<MaterialChangeDto> getList(MaterialChangeVo materialChangeVo, PageQuery pageQuery) {
        //查询库存列表
        return materialChangeService.getList(materialChangeVo, pageQuery);
    }

}
